package cn.ztelovecly.springboot.framework.message;

import cn.ztelovecly.springboot.framework.util.SettingUtil;

public abstract class BaseMessage {

    private static String postfix = SettingUtil.getProperty("", "mq.topic.postfix").toUpperCase();
    private static String prefix = SettingUtil.getProperty("", "mq.topic.prefix").toUpperCase();

    /**
     * 消息主题
     */
    private String msg_topic;

    /**
     * 消息标签
     */
    private String msg_tag;

    /**
     * 消息主键
     */
    private String msg_key;

    public String getMsg_topic(){
        if (postfix == null || postfix.equals("") || postfix.equals("NONE")) {
            postfix = "";
        } else {
            if (!postfix.startsWith("_")){
                postfix = "_" + postfix;
            }
        }
        if (prefix == null || prefix.equals("") || prefix.equals("NONE")) {
            prefix = "";
        } else {
            if (!prefix.endsWith("_")){
                prefix = prefix + "_";
            }
        }
        return prefix + msg_topic + postfix;
//           if(postfix==null || postfix.equals("") || postfix.equals("NONE")) {
//               return msg_topic;
//           }else{
//               return msg_topic+"_"+postfix;
//           }
    }

    public String getMsg_tag() {
        return msg_tag;
    }

    public String getMsg_key() {
        return msg_key;
    }

    public void setMsg_key(String msg_key) {
        this.msg_key = msg_key;
    }

    public void setMsg_topic(String msg_topic) {
        this.msg_topic = msg_topic;
    }
}
